package com.example.demo;

import java.lang.ref.SoftReference;

public class SoftReferenceTest {
    public static void main(String[] args) {
        //-Xms15M -Xmx15M
        SoftReference<byte[]> reference = new SoftReference<>(new byte[1024*1024*10]);
        System.out.println(reference.get());
        //调用GC 等待10s 保证GC尽可能会执行
        System.gc();
        try {
            Thread.sleep(10*1000L);
        }catch (Exception e){
            e.printStackTrace();
        }
        System.out.println(reference.get());

        byte[] bytes = new byte[1024*1024*10];
        System.out.println(reference.get());

    }
}
